package main

import (
	"encoding/json"
	"fmt"
)

type user struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

func (u user) change() {
	str, _ := json.Marshal(map[string]interface{}{
		"id":   10,
		"name": "zhangsan",
	})
	err := json.Unmarshal(str, &u)
	if err != nil {
		fmt.Println("unmarshal err:", err)
	}
}

func main() {
	//u := user{}
	//u.change()
	//fmt.Println(u)
	//cnt := make(map[int][2]int)
	//cnt[0] = [2]int{10}
	//fmt.Println(cnt[0][0])

	//ctx := context.Background()
	//redisClient := redis.NewClient(&redis.Options{
	//	Addr: "127.0.0.1:6379",
	//})
	//push := redisClient.LPop(ctx, "limit_list")
	//fmt.Println(push.String())
	//fmt.Println(push)
	//fmt.Println(push.Err())
	//num, _ := strconv.Atoi("")
	//fmt.Println(num)

	//redisClient.ZAdd(ctx, "test:zadd", redis.Z{Score: 10, Member: "1"})
	//redisClient.ZAdd(ctx, "test:zadd", redis.Z{Score: 20, Member: "2"})
	//redisClient.ZAdd(ctx, "test:zadd", redis.Z{Score: 30, Member: "3"})
	//redisClient.ZAdd(ctx, "test:zadd", redis.Z{Score: 40, Member: "4"})
	//zRange := redisClient.ZRangeByScore(ctx, "test:zadd", &redis.ZRangeBy{Min: "10", Max: "20"})
	//fmt.Println(zRange.Result())
	//fmt.Println(zRange.Val())
	//http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
	//	r.Context()
	//})

	//http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
	//	ctx, _ := context.WithTimeout(r.Context(), time.Second)
	//	resultChan := make(chan string)
	//
	//	go func() {
	//		// 模拟耗时操作
	//		time.Sleep(2 * time.Second)
	//		resultChan <- "result"
	//	}()
	//
	//	select {
	//	case <-ctx.Done():
	//		// 请求取消或超时
	//		http.Error(w, "request canceled", http.StatusRequestTimeout)
	//	case result := <-resultChan:
	//		// 正常返回结果
	//		fmt.Fprintln(w, result)
	//	}
	//})
	//
	//err := http.ListenAndServe(":9000", nil)
	//fmt.Println(err)
	//rm := runtime.MemStats{}
	//runtime.ReadMemStats(&rm)
	//go func() {
	//	for {
	//		fmt.Printf("%+v", rm)
	//	}
	//}()
	//go func() {
	//	for {
	//		fmt.Println("do something")
	//
	//	}
	//}()
	//<-time.After(time.Second)
	//a := 0
	//fmt.Scanf("%d\n", &a)
	//arr := make([]int, a)
	//for i := range a {
	//	b := 0
	//	fmt.Scanf("%d", &b)
	//	arr[i] = b
	//}
	//fmt.Println(arr)

	m := make(map[int]any, 10)
	fmt.Println(m[2])
}
